<template>
  <div class="app-container">
    <!--工具栏-->
    <div class="head-container">
      <!--如果想在工具栏加入更多按钮，可以使用插槽方式， slot = 'left' or 'right'-->
      <crudOperation :permission="permission" />
      <!--表单组件-->
      <el-dialog :close-on-click-modal="false" :before-close="crud.cancelCU" :visible.sync="crud.status.cu > 0" :title="crud.status.title" width="500px">
        <el-form ref="form" :model="form" :rules="rules" size="small" label-width="80px">
          <el-form-item label="主键ID" prop="bisQyId">
            <el-input v-model="form.bisQyId" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="居家机构ID">
            <el-input v-model="form.bisQyHljgId" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="照护申请ID">
            <el-input v-model="form.bisQyZhsqId" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="签约时间">
            <el-input v-model="form.bisQyQysj" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="签约状态">
            <el-input v-model="form.bisQyZt" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="业务类型">
            <el-input v-model="form.ywlx" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="录入人">
            <el-input v-model="form.lrr" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="录入人姓名">
            <el-input v-model="form.lrrxm" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="录入人部门">
            <el-input v-model="form.lrbm" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="录入人部门名称">
            <el-input v-model="form.lrbmmc" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="录入时间">
            <el-input v-model="form.lrsj" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="更新人">
            <el-input v-model="form.gxr" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="更新人姓名">
            <el-input v-model="form.gxrxm" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="更新人部门">
            <el-input v-model="form.gxbm" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="更新人部门名称">
            <el-input v-model="form.gxbmmc" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="更新时间">
            <el-input v-model="form.gxsj" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="是否有效">
            <el-input v-model="form.sfyx" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="备注">
            <el-input v-model="form.bz" style="width: 370px;" />
          </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button type="text" @click="crud.cancelCU">取消</el-button>
          <el-button :loading="crud.status.cu === 2" type="primary" @click="crud.submitCU">确认</el-button>
        </div>
      </el-dialog>
      <!--表格渲染-->
      <el-table ref="table" v-loading="crud.loading" :data="crud.data" size="small" style="width: 100%;" @selection-change="crud.selectionChangeHandler">
        <el-table-column type="selection" width="55" />
        <el-table-column prop="bisQyId" label="主键ID" />
        <el-table-column prop="bisQyHljgId" label="居家机构ID" />
        <el-table-column prop="bisQyZhsqId" label="照护申请ID" />
        <el-table-column prop="bisQyQysj" label="签约时间" />
        <el-table-column prop="bisQyZt" label="签约状态" />
        <el-table-column prop="ywlx" label="业务类型" />
        <el-table-column prop="lrr" label="录入人" />
        <el-table-column prop="lrrxm" label="录入人姓名" />
        <el-table-column prop="lrbm" label="录入人部门" />
        <el-table-column prop="lrbmmc" label="录入人部门名称" />
        <el-table-column prop="lrsj" label="录入时间" />
        <el-table-column prop="gxr" label="更新人" />
        <el-table-column prop="gxrxm" label="更新人姓名" />
        <el-table-column prop="gxbm" label="更新人部门" />
        <el-table-column prop="gxbmmc" label="更新人部门名称" />
        <el-table-column prop="gxsj" label="更新时间" />
        <el-table-column prop="sfyx" label="是否有效" />
        <el-table-column prop="bz" label="备注" />
        <el-table-column v-if="checkPer(['admin','qy:edit','qy:del'])" label="操作" width="150px" align="center">
          <template slot-scope="scope">
            <udOperation
              :data="scope.row"
              :permission="permission"
            />
          </template>
        </el-table-column>
      </el-table>
      <!--分页组件-->
      <pagination />
    </div>
  </div>
</template>

<script>
import crudQy from '@/api/business/qy'
import CRUD, { presenter, header, form, crud } from '@crud/crud'
import rrOperation from '@crud/RR.operation'
import crudOperation from '@crud/CRUD.operation'
import udOperation from '@crud/UD.operation'
import pagination from '@crud/Pagination'

const defaultForm = { bisQyId: null, bisQyHljgId: null, bisQyZhsqId: null, bisQyQysj: null, bisQyZt: null, ywlx: null, lrr: null, lrrxm: null, lrbm: null, lrbmmc: null, lrsj: null, gxr: null, gxrxm: null, gxbm: null, gxbmmc: null, gxsj: null, sfyx: null, bz: null }
export default {
  name: 'Qy',
  components: { pagination, crudOperation, rrOperation, udOperation },
  mixins: [presenter(), header(), form(defaultForm), crud()],
  cruds() {
    return CRUD({ title: '签约', url: 'api/qy', idField: 'bisQyId', sort: 'bisQyId,desc', crudMethod: { ...crudQy }})
  },
  data() {
    return {
      permission: {
        add: ['admin', 'qy:add'],
        edit: ['admin', 'qy:edit'],
        del: ['admin', 'qy:del']
      },
      rules: {
        bisQyId: [
          { required: true, message: '主键ID不能为空', trigger: 'blur' }
        ]
      }}
  },
  methods: {
    // 钩子：在获取表格数据之前执行，false 则代表不获取数据
    [CRUD.HOOK.beforeRefresh]() {
      return true
    }
  }
}
</script>

<style scoped>

</style>
